package jdbcConnect;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public interface Register {
    boolean Login(Connection conn) throws SQLException;
}
class TeacherLogin implements Register {
    Statement stmt;
    ResultSet rs;
    String loginuser;
    String loginpwd;
    public String getLoginuser() {
        return loginuser;
    }
    public String getLoginpwd() {
        return loginpwd;
    }

    public void setLogin(String loginuser,String loginpwd) {
        this.loginpwd = loginpwd;
        this.loginuser=loginuser;
    }





    @Override
    public boolean Login(Connection conn) throws SQLException {

        String sql="select * from Teacher where user = '" + loginuser + "' and password = '" + loginpwd + "'";
        stmt=conn.createStatement();
        rs=stmt.executeQuery(sql);
        if(rs.next()){
            return true;
        }else return false;
    }
}
class StudentLogin implements Register{
    Statement stmt;
    ResultSet rs;
    String loginuser;
    String loginpwd;

    public StudentLogin(String loginuser,String loginpwd) {
        this.loginuser = loginuser;
        this.loginpwd=loginpwd;
    }



    @Override
    public boolean Login(Connection conn) throws SQLException {
        String sql="select * from student where StudentNo = '" + loginuser + "' and password = '" + loginpwd + "'";
        stmt=conn.createStatement();
        rs=stmt.executeQuery(sql);
        if(rs.next()){
            return true;
        }else return false;

    }
}

